<template>
  <div class="goods-list-item" @click='itemClick'>
    <!-- <a :href="goodsItem.link"> -->
      <img v-lazy="goodsItem.show.img" alt=""  @load="imageLoad"/>
      <div class="goods-info">
        <p>{{ goodsItem.title }}</p>
        <span class="price">￥{{ goodsItem.price }}</span>
        <span class="collect">⭐{{ goodsItem.cfav }}</span>
      </div>
    <!-- </a> -->
  </div>
</template>

<script>
export default {
  name: "GoodsListItem",
  props: {
    goodsItem: {
      type: Object,
      default() {
        return {
        };
      },
    },
  },
  data() {
    return {};
  },

  mounted() {},

  methods: {
    imageLoad(){
      // console.log('imageLoad');
      // 监听图片加载
      this.$bus.$emit('imgLoad');
    },
    itemClick(){
      this.$router.push('/detail/'+ this.goodsItem.iid)
    }
  },
};
</script>

<style lang="css" scoped>
.goods-list-item {
  /* margin: 0 auto; */
  padding-bottom: 40px;
  position: relative;
  /* display: inline-block; */
  width: 48%;
  /* padding: 0 15px 40px; */
}
img {
  width: 100%;
  border-radius: 5px;
}
.goods-info {
  font-size: 12px;
  position: absolute;
  bottom: 5px;
  left: 0;
  right: 0;
  overflow: hidden;
  text-align: center;
}
.goods-info p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 3px;
}
.goods-info .price {
  color: var(--color-high-text);
  margin-right: 20px;
}
</style>